<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<s:url value="/css/style.css"/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<s:url value="/js/jquery.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/common.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jquery.form.js"/>"></script>
<script type="text/javascript" src="<s:url value="/js/jquery.validate.js"/>"></script>
<script type="text/javascript">
function doSubmit(){
	// here is validate form .
	if(window.confirm('Save modify?')) {
		parent.reset();
		$('#editForm').submit();
	}
}
 

function remove(){
	if(window.confirm('Save modify?')) {
		parent.reset();
		$.ajax({
			type:'post',
			url : '<s:url value="/system/Menu/delete" />',
			data:{id:$('#id').val()},
			success:function(){	
				alert("Delete current menu successfully!");
				parent.list.location.reload();
				}
			});
	}
}
$(function(){
	$('#editForm').validate();
	if($.trim($('#result').text())!=''){
		//popupDiv('pop-div');
		parent.list.location.reload();
	}
	
	$('#parentId').val(<%=request.getParameter("parentId")==null?"":request.getParameter("parentId")%>);
	$('#parentName').val('<%=request.getParameter("parentName")==null?"":request.getParameter("parentName")%>');
	
});

</script>
<title><s:text name="system.title" /></title>
</head>
<body>
<s:form action="Menu/save" namespace="/system" method="post" id="editForm" name="editForm">
		<s:hidden name="id" id="id"></s:hidden>
 
		<table width="100%" border="0" cellpadding="3" cellspacing="1" class="margin">
			<tr>
				<td align="right" width="50%" class="tablecolour5">Menu Name<font color="red">*</font>:</td>
				<td width="50%" class="tablecolour5"><s:textfield name="name" cssClass="input2 required" size="24" /></td>
			</tr>
			<tr>
				<td align="right" width="50%" class="tablecolour5">link:</td>
				<td width="50%" class="tablecolour5"><s:textfield name="link" cssClass="input2" size="24" /></td>
			</tr>
			<tr>
				<td align="right" width="50%" class="tablecolour5">target<font color="red">*</font></td>
				<td width="50%" class="tablecolour5"><s:textfield name="target" cssClass="input2 required" size="24" /></td>
			</tr>
			<tr>
				<td align="right" width="50%" class="tablecolour5">Level<font color="red">*</font></td>
				<td width="50%" class="tablecolour5"><s:textfield name="level" cssClass="input2 required number" size="24" /></td>
			</tr>
			<tr>
				<td align="right" width="50%" class="tablecolour5">Parent</td>
				<td width="50%" class="tablecolour5"><s:hidden name="parent.id" id="parentId"/><s:textfield name="parent.name" id="parentName" readonly="true" cssClass="input2" size="24" /></td>
			</tr>
			<tr>
				<td align="right" width="50%" class="tablecolour5">Order</td>
				<td width="50%" class="tablecolour5"><s:textfield name="order" cssClass="input2 number" size="24" /></td>
			</tr>
			 
		<tr>
			<td align="center" colspan="2" height="50" class="tablecolour5">
			<input type="button"   value="Save"  onclick="doSubmit();"  /> 
			
			<%if(request.getParameter("id")!=null&&!request.getParameter("id").equals("")){ %>
			<input name="Delete" type="button" value="Delete" onclick="remove();" />
			<%} %>
				</td>
		</tr>
		</table>
		
		 

<div id='pop-div' style="width: 300px;" class="pop-box">  
  <s:include value="/common/confirm.jsp"></s:include>   
</div>
</s:form>
</body>
</html>